import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 出入库管理信息 */
export interface StoreManage {
  id: number // id
  customerAccount?: string // 客户账号
  operDate: string | Dayjs // 日期
  drawingNumber: string // 图号
  productName: string // 品名
  inAmount?: number // 入库数量
  outAmount?: number // 出库数量
}

// 出入库管理 API
export const StoreManageApi = {
  // 查询出入库管理分页
  getStoreManagePage: async (params: any) => {
    return await request.get({ url: `/business/store-manage/page`, params })
  },

  // 查询出入库管理详情
  getStoreManage: async (id: number) => {
    return await request.get({ url: `/business/store-manage/get?id=` + id })
  },

  // 新增出入库管理
  createStoreManage: async (data: StoreManage) => {
    return await request.post({ url: `/business/store-manage/create`, data })
  },

  // 修改出入库管理
  updateStoreManage: async (data: StoreManage) => {
    return await request.put({ url: `/business/store-manage/update`, data })
  },

  // 删除出入库管理
  deleteStoreManage: async (id: number) => {
    return await request.delete({ url: `/business/store-manage/delete?id=` + id })
  },

  /** 批量删除出入库管理 */
  deleteStoreManageList: async (ids: number[]) => {
    return await request.delete({ url: `/business/store-manage/delete-list?ids=${ids.join(',')}` })
  },

  // 导出出入库管理 Excel
  exportStoreManage: async (params) => {
    return await request.download({ url: `/business/store-manage/export-excel`, params })
  },

  // 下载导入模板
  importTemplate: async () => {
    return request.download({ url: '/business/store-manage/get-import-template' })
  }
}
